<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>京东羊毛脚本控制面板</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0 ,user-scalable=no">
	<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
	<script type="text/javascript" src="./js/jquery.min.js"></script>
	<script type="text/javascript" src="./js/sweetalert2.js"></script>
	<link rel="stylesheet" type="text/css" href="./css/main.css">
</head>

<body>
	<div class="login-form">
		<h1>京东羊毛脚本控制面板</h1>
		<form action="auth" method="POST">
			<input type="text" name="username" class="username" placeholder="Username" required>
			<input type="password" name="password" class="password" placeholder="Password" required>
			<input type="submit" id="login">
		</form>
	</div>

	<script>
		$("#login").click(function () {
			let timeStamp = (new Date()).getTime()
			$user = $(".username").val();
			$password = $(".password").val();
			$.post('./auth?t='+timeStamp, { username: $user, password: $password }, function (data) {
				if (data.err == 0) {
					window.location.href = "./home";
				} else {
					Swal.fire({
						text: data.msg
					})
				}
			});
			return false;
		});
	</script>
</body>

</html>
